﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _008_观察者模式
{
    class Cat
    {
        private string name;
        private string color;

        // 声明一个事件   
        public event Action catCome;

        public Cat(string name,string color)
        {
            this.name = name;
            this.color = color;
        }

        public void CatComing()
        {
            Console.WriteLine($"{color}的猫:{name}过来了---");
            if (catCome!=null)
            {
                catCome();
            }
            
        }

    }
}
